package org.swig.jirr;

/**
 * @author sad
 */
public class ICustomizableTriangleMeshNode extends ISceneNode {

    public ICustomizableTriangleMeshNode(long pointer, boolean own) {
        super(pointer, own);
    }

    public int getVerticesCount() {
        return JirrJNI.ICustomizableTriangleMeshNode_getVerticesCount(swigCPtr);
    }

    public int getIndicesCount() {
        return JirrJNI.ICustomizableTriangleMeshNode_getIndicesCount(swigCPtr);
    }

    public void recalculate() {
        JirrJNI.ICustomizableTriangleMeshNode_recalculate(swigCPtr);
    }

    public S3DVertex[] getVertices() {
        long[] verticesPointer = JirrJNI.ICustomizableTriangleMeshNode_getVertices(swigCPtr);
        S3DVertex[] vertices = new S3DVertex[verticesPointer.length];
        for (int i = 0; i < verticesPointer.length; i++) {
            vertices[i] = new S3DVertex(verticesPointer[i], false);
        }

        return vertices;
    }

    public int[] getIndices() {
        int[] indices = JirrJNI.ICustomizableTriangleMeshNode_getIndicies(swigCPtr);
        return indices;
    }

    public void setIndices(int[] indices) {
        JirrJNI.ICustomizableTriangleMeshNode_setIndicies(swigCPtr, indices);
    }

    public void setVertices(S3DVertex[] vertices) {
        long[] pointers = new long[vertices.length];
        for (int i = 0; i < pointers.length; i++) {
            pointers[i] = S3DVertex.getCPtr(vertices[i]);
        }

        JirrJNI.ICustomizableTriangleMeshNode_setVerticies(swigCPtr, pointers);
    }

    public S3DVertex addVertex(S3DVertex vertex) {
        long[] verticesPointer = JirrJNI.ICustomizableTriangleMeshNode_getVertices(swigCPtr);
        long[] newArray = new long[verticesPointer.length + 1];
        System.arraycopy(verticesPointer, 0, newArray, 0, verticesPointer.length);
        newArray[verticesPointer.length] = S3DVertex.getCPtr(vertex);
        JirrJNI.ICustomizableTriangleMeshNode_setVerticies(swigCPtr, newArray);
        long[] vp = JirrJNI.ICustomizableTriangleMeshNode_getVertices(swigCPtr);
        if (vp.length == 0) {
            return null;
        }
        return new S3DVertex(vp[vp.length - 1], false);
    }
}
